﻿using System.Collections;
using System.Collections.Generic;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.IO;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
   
    public partial class ITXEXRPT
    {
        public string UBTPrint(ref bool IsReturn)
        {
            if (app.company != "UBT")
                return filename;
            Helper.GetDate(ref date, ref year, ref month, ref day);
            switch (DocType)
            {


                case "UBTVKPPROD":
                    destfolder = SetFolder(Root, "投产通知单");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("VKPOS"))
                        IsReturn = true;
                    dwOrder = dsSource.Tables["VKPOS"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }
                    KRS = dwOrder["VKPART"].ToString().Trim().Replace("/", "-");
                    order = KRS;
                    DestFile = destfolder + "\\投产通知单-" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTVKPPROD";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTVKPPROD(dsSource);
                    break;
                case "UBTVK04CN":
                    destfolder = SetFolder(Root, "内销合同");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("VKPOS"))
                        IsReturn = true;
                    dwOrder = dsSource.Tables["VKPOS"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }
                    order = dwOrder["VKPAUFKRS"].ToString().Trim() + dwOrder["VKPAUFLFD"].ToString();
                    DestFile = destfolder + "\\内销合同-" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTVK04CN";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTVK04CN(dsSource);
                    break;
                case "UBTVK04EN":
                    destfolder = SetFolder(Root, "外销合同");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("VKPOS"))
                        IsReturn = true;
                    dwOrder = dsSource.Tables["VKPOS"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }
                    order = dwOrder["VKPAUFKRS"].ToString().Trim() + dwOrder["VKPAUFLFD"].ToString();
                    DestFile = destfolder + "\\外销合同-" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTVK04EN";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTVK04EN(dsSource);
                    break;
                case "UBTDXDOC":
                    destfolder = SetFolder(Root, "排产");
                    #region====文件命名============== 
                    order = date;
                    DestFile = destfolder + "\\定型排产-" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = order;
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTDXDOC(dsSource);
                    break;
                case "UBTWVLB":
                    destfolder = SetFolder(Root, "标签");
                    #region====文件命名==============
                    order = DateTime.Now.ToLocalTime().ToFileTime().ToString();
                    DestFile = destfolder + "\\标签" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTWVLB";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTWVLB(dsSource);
                    break;
                case "UBTVK02":
                    destfolder = SetFolder(Root, "销售统计");
                    #region====文件命名==============
                    order = "销售统计" + date;
                    DestFile = destfolder + "\\" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTVK02";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTVK02(dsSource);
                    break;
                case "UBTAB55WB":
                    destfolder = SetFolder(Root, "坯布标签");
                    #region====文件命名==============
                    dwOrder = dsSource.Tables["WBBST"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }

                    order = dwOrder["WBBAUFKRS"].ToString().Trim() + dwOrder["WBBAUFLFD"].ToString().Trim() + dwOrder["WBBAUFPOS"].ToString().Trim();
                    DestFile = destfolder + "\\坯布标签" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTAB55WB";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTAB55WB();
                    break;
                case "UBTFQI03E":
                    destfolder = SetFolder(Root, "成品标签");
                    #region====文件命名==============
                    dwOrder = dsSource.Tables["WBBST"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }

                    order = dwOrder["WBBSTKNR"].ToString().Trim();
                    DestFile = destfolder + "\\成品标签" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTFQI03E";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTFQI03E();
                    break;
                case "UBTAB05BTP":
                    destfolder = SetFolder(Root, "标签");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("ABPOS"))
                        IsReturn = true;
                    dwOrder = dsSource.Tables["ABPOS"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }
                    order = dwOrder["ABPTP"].ToString().Trim();
                    DestFile = destfolder + "\\分批标签" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTAB05BTP";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTAB05BTP();
                    break;
                case "UBTRQI03":
                    destfolder = SetFolder(Root, "坯布检验");
                    #region====文件命名==============
                    order = "坯布检验" + date;
                    DestFile = destfolder + "\\" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTRQI03";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTRQI03(dsSource);
                    break;
                case "UBTXB":
                    destfolder = SetFolder(Root, "坯布修布");
                    #region====文件命名==============
                    order = "坯布修布" + date;
                    DestFile = destfolder + "\\" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "UBTXB";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    UBTXB(dsSource);
                    break;


            }
            return filename;
        }

    }
}
